package com.elong.android.specialhouse.activity;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.alibaba.fastjson.JSON;
import com.elong.android.specialhouse.R;
import com.elong.android.specialhouse.adapter.common.BaseViewHolder;
import com.elong.android.specialhouse.adapter.common.PowerAdapter;
import com.elong.android.specialhouse.entity.PushContent;
import com.elong.android.specialhouse.entity.PushMessageVo;
import com.elong.android.specialhouse.utils.DateTimeUtils;

/**
 * 展示系统通知消息列表
 * 
 * @author boyan
 * 
 */
public class SystemNotifitionListAcivity extends SystemMessageListActivity
		implements OnItemClickListener {

	@Override
	protected void setCommonHead() {
		setHeader(R.string.system_notification);

	}

	@Override
	protected void setUpMsgList() {
		mAdapter = new PowerAdapter<PushMessageVo>(this,
				R.layout.item_system_notification, messageList) {
			@Override
			protected void convert(BaseViewHolder holder, PushMessageVo item) {
				holder.setText(R.id.notification_time,
						DateTimeUtils.getFormatTime(item.sendTime));
				try {
					PushContent content = JSON.parseObject(item.content, PushContent.class);
					holder.setText(R.id.notifaciton_title, content.title);
					holder.setText(R.id.notification_content, content.desc);
				} catch (Exception e) {
					e.printStackTrace();
				}
				// TODO 其他通知的分类展示
			}
		};
		mListView.setAdapter(mAdapter);
		// TODO 暂时先不做点击跳转详情
		// mListView.setOnItemClickListener(this);

	}

	@Override
	protected void setDataType() {
		req.msgType = 2;
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		Intent in = new Intent(SystemNotifitionListAcivity.this,
				LatestActivity.class);
		startActivity(in);

	}

}
